#include <iostream>
#include <vector>
using namespace std;

vector<int> findAnagrams(string s, string p)
{
    int hash1[26] = { 0 };
    for (int i = 0; i < p.size(); i++)
    {
        hash1[p[i] - 'a']++;
    }
    int m = p.size();
    int hash2[26] = { 0 };
    vector<int> r;
    for (int left = 0, right = 0, count = 0; right < s.size(); right++)
    {
        hash2[s[right] - 'a']++;
        if (hash2[s[right] - 'a'] <= hash1[s[right] - 'a']) count++;

        if (right - left + 1 > m)
        {
            if (hash2[s[left] - 'a'] <= hash1[s[left] - 'a']) count--;
            hash2[s[left++] - 'a']--;
        }

        if (count == m)
        {
            r.push_back(left);
        }
    }
    return r;
}

int main()
{
    string s("cbaebabacd");

    return 0;
}